package com.ourteam.product.api;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.ui.dao.IProductUIActionGroupRelateDAO;
import com.ourteam.product.ui.dao.ProductUIActionGroupRelateDAOQueryBean;
import com.ourteam.product.ui.domain.ProductUIActionGroupRelateBean;

public class ProductUIActionGroupRelateSearchModel extends AbstractSearchModel<ProductUIActionGroupRelateDAOQueryBean> {

	private long actionGroupId;

	public long getActionGroupId() {
		return actionGroupId;
	}

	public void setActionGroupId(long actionGroupId) {
		this.actionGroupId = actionGroupId;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductUIActionGroupRelateBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductUIActionGroupRelateDAOQueryBean queryBean) throws Exception {

		ProductUIActionGroupRelateDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (actionGroupId != 0) {
			criteria.andActionGroupIdEqualTo(actionGroupId);
		}

		if (queryBean.getSortProperties().isEmpty()) {
			queryBean.setSortProperty(IProductUIActionGroupRelateDAO.SortIndex);
		}
	}

}
